package cn.itsource.controller;

import cn.itsource.AjaxResult;
import cn.itsource.User;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginApplication {

    @PostMapping("/login")
    /*@RequestMapping("/login")*/
    public AjaxResult login(@RequestBody User user){
        String username = user.getUsername();
        String password = user.getPassword();
        if("admin".equals(username) && "admin".equals(password)){
            AjaxResult ajaxResult = AjaxResult.me().setSuccess(true).setMessage("欢迎xx登录源码时代官网")
                    .setRestObj(user);
            return ajaxResult;
        }
        AjaxResult ajaxResult = AjaxResult.me().setSuccess(false).setMessage("账号或密码错误");
        return ajaxResult;
    }
}
